//
//  TalkInfoViewController.m
//  BasketballClub
//
//  Created by 孙鸿吉 on 16/1/19.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "TalkInfoViewController.h"
#import "TalkInfoView.h"
#import <AVOSCloud.h>
@interface TalkInfoViewController ()
@property (nonatomic,strong)TalkInfoView *talkInfoView;
@property (nonatomic,assign)NSInteger talkCount;
@property (nonatomic,strong)NSMutableArray *array;
@end

@implementation TalkInfoViewController
- (void)loadView
{
    self.talkInfoView = [[TalkInfoView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.view = self.talkInfoView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.talkInfoView.backgroundColor = ColorHex(0x0d1c38);
    //返回按钮
    [self.talkInfoView.cancleButton addTarget:self action:@selector(returnBeforeAction) forControlEvents:UIControlEventTouchUpInside];
    //发送按钮
    [self.talkInfoView.sendButton addTarget:self action:@selector(sendButtonAction) forControlEvents:UIControlEventTouchUpInside];
    //添加手势
    UIScreenEdgePanGestureRecognizer *edgeGR = [[UIScreenEdgePanGestureRecognizer alloc]initWithTarget:self action:@selector(edgeGR)];
    [self.talkInfoView addGestureRecognizer:edgeGR];
    self.talkInfoView.userInteractionEnabled = YES;
    edgeGR.edges = UIRectEdgeLeft;

}
#pragma mark - 取消按钮方法
- (void)returnBeforeAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - 发送按钮方法
- (void)sendButtonAction
{

    AVUser *current = [AVUser currentUser];
    NSString *key = [NSString stringWithFormat:@"talk%ld",self.passID];
    NSString *stirng = [NSString stringWithFormat:@"用户:%@",current.username];
    AVObject *object = [AVObject objectWithClassName:@"Talk"];
    [object setObject:stirng forKey:@"userName"];
    [object setObject:self.talkInfoView.returnTextView.text forKey:key];
    [object saveInBackground];
    [self dismissViewControllerAnimated:YES completion:nil];
    
    
}
#pragma mark - 手势方法实现
- (void)edgeGR
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
